
public abstract class StringObjectPairList extends List {

	// adds element to list if instance of StringObjectPair, false if not of correct type
	@Override
	public boolean add(Object element) {
		if(!(element instanceof StringObjectPair)) {
			return false;
		}
		return super.add(element);
	}
	
	// returns StringObjectPair with id (position in list), null if id invalid or not found
	@Override
	public StringObjectPair getElement(Object objId) {
		if(!(objId instanceof Integer)) {
			return null;
		}
		int pos = (Integer)objId;
		
		Iter it = iterator();
		int count = 0;
		while(it.hasNext()) {
			StringObjectPair e = (StringObjectPair)it.next();
			if(pos == count) {
				return e;
			}
			count++;
		}
		return null;
	}
}
